<!-- 好生活资金池详情 -主页-->
<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane
        :key="item.name"
        v-for="(item) in tabListData"
        :label="item.label"
        :name="item.name"
      >
        <component :is="item.name" :userInfo="userInfo" :active="activeName === item.name"></component>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import api from "@/api/apiPath";

import payListDetail from "./payListDetail"; //支付订单
import returnRecordDetail from "./returnRecordDetail"; //回款确认
import brokerSettlementDetail from "./brokerSettlementDetail"; //经纪人结佣记录
import brokerageSettlementDetail from "./brokerageSettlementDetail"; //经纪公司结佣记录
import brokerRewardDetail from "./brokerRewardDetail"; //经纪人奖励结佣记录
import efCommDetail from "./efCommDetail"; //好生活结佣记录
import developCommDetail from "./developCommDetail"; //开发商结佣记录
import internetTwitterDetail from "./internetTwitterDetail"; //网络推客结佣纪录

export default {
  components: {
    payListDetail,
    returnRecordDetail,
    brokerSettlementDetail,
    brokerageSettlementDetail,
    brokerRewardDetail,
    efCommDetail,
    developCommDetail,
    internetTwitterDetail
  },
  data() {
    return {
      userInfo: {
        allInfo: "",
        orderId: "",
        mergeId: ""
      },
      rule: "",
      activeName: "payListDetail",
      /*  
        显示规则
        netWork  :网络推客
        all:默认显示
        since:自来客
      */
      tabListData: [
        {
          label: "支付订单",
          name: "payListDetail",
          power: ["network", "all", "since"]
        },
        {
          label: "回款确认",
          name: "returnRecordDetail",
          power: ["network", "all", "since"]
        },
        {
          label: "网络推客结佣纪录",
          name: "internetTwitterDetail",
          power: ["network"]
        },
        {
          label: "经纪人结佣记录",
          name: "brokerSettlementDetail",
          power: ["all"]
        },
        {
          label: "经纪公司结佣记录",
          name: "brokerageSettlementDetail",
          power: ["all"]
        },
        {
          label: "经纪人奖励结佣记录",
          name: "brokerRewardDetail",
          power: ["all"]
        },
        {
          label: "好生活结佣记录",
          name: "efCommDetail",
          power: ["network", "all", "since"]
        },
        {
          label: "开发商结佣记录",
          name: "developCommDetail",
          power: ["network", "all", "since"]
        }
      ]
    };
  },
  methods: {
    handleClick(a) {},
    getDetail(orderId) {
      this.axios.get(api.getCashPoolDetail + "/" + orderId).then(res => {
        if (res.data.code == 200) {
          this.userInfo.allInfo = res.data.data;
        }
      });
    },
    tabShowRegular(brokerType) {
      let brokerTypeTabsMap = {
        "0": "network",
        "-1": "since"
      };
      return brokerTypeTabsMap[brokerType] || "all";
    }
  },
  created() {
    let { orderId, mergeId, brokerType } = this.$route.query;
    this.userInfo.orderId = orderId;
    this.userInfo.mergeId = mergeId;
    this.userInfo.brokerType = brokerType;

    this.tabListData = this.tabListData.filter(t =>
      t.power.includes(this.tabShowRegular(brokerType))
    );
    this.getDetail(orderId);
  },
  destroyed() {},
  filters: {}
};
</script>

<style lang="stylus"></style>
